//Header files
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "common.h"

//Declaring matrices A, B, & C
unsigned int matrixA[MATRIX_SIZE][MATRIX_SIZE]  QWORD_ALIGNED;
unsigned int matrixB[MATRIX_SIZE][MATRIX_SIZE]  QWORD_ALIGNED;
unsigned int matrixC[MATRIX_SIZE][MATRIX_SIZE]  QWORD_ALIGNED;

int main(){

  	//variable declarations
	int i,j,k;		//used to reference matrix indexes
	srand( time(NULL) );	//initialize timer

	// Initializing matrix elements
	for(i=0; i<MATRIX_SIZE; i++)
	{
		for(j=0; j<MATRIX_SIZE; j++)
		{
			matrixA[i][j] = (int) rand()%10;
			matrixB[i][j] = (int) rand()%10;
			matrixC[i][j]=0;                
		}
	}

	//Printing matrixA
	printf("\n\nMatrix A\n");        

	for(i=0;i<MATRIX_SIZE;i++)
	{            
		for(j=0;j<MATRIX_SIZE;j++)            
		{                
			printf("%u ",matrixA[i][j]);            
		}            
		printf("\n");        
	}

	//Printing matrixB
	printf("\n\nMatrix B\n");        

	for(i=0;i<MATRIX_SIZE;i++)
	{            
		for(j=0;j<MATRIX_SIZE;j++)            
		{                
			printf("%u ",matrixB[i][j]);            
		}            
		printf("\n");        
	}

	//Printing matrixC and computing matrix multiplication
	printf("\n\nResult of AB\n");        

	for(i=0;i<MATRIX_SIZE;i++)
	{            
		for(j=0;j<MATRIX_SIZE;j++)            
		{                
			for(k=0;k<MATRIX_SIZE;k++)                
			{                    
				matrixC[i][j]+=matrixA[i][k]*matrixB[k][j];                    
			}                
			printf("%u ",matrixC[i][j]);            
		}            
		printf("\n");        
	}
	return 0;
}
